<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "prf_config".
 *
 * @property integer $id
 * @property string $name
 * @property string $config_value
 * @property string $description
 * @property string $updatetime
 */
class PrfConfig extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'prf_config';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['config_name', 'config_attribute','config_value'], 'required'],
            [['config_value'],'integer'],
            [['config_name', 'config_attribute'], 'unique'],
            [['updatetime'], 'safe'],
            [['config_name'], 'string', 'max' => 50],
            [['config_value', 'description'], 'string', 'max' => 200]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'config_name' => Yii::t('app','Config Name'),
            'config_attribute' => Yii::t('app','Config Attribute'),
            'config_value' => Yii::t('app','Config Value'),
            'description' => Yii::t('app','Description'),
            'updatetime' => Yii::t('app','Updatetime'),
        ];
    }
    public static function get_config_value($config_name)
    {
    	return self::findOne(['config_attribute' => $config_name])->config_value;
    }
}
